%==========================================================================
% Name : apodizeFID
% Author : Seabiscuit
% Created Date : 03 Mars 2013
% Modified Data : 06 Mars 2013
% Arguments : (complex number signal data, 
%                 wave frequency,
%                 bandwidth,
%                 shape)
% Description : Apodization of a time-domain signal
%==========================================================================

function fsignal = apodizeFID(complexFidData, aplw, bandwidth, u_events)
%==========================================================================
% Data processing
%==========================================================================

    datapoint=size(complexFidData);                          % parameters
    interval=1/bandwidth;                                    % the unit is sec   
    begtime=0E0;
    t = (begtime+(0:interval:(datapoint(1)-1)*interval));    % the unit is sec
    
%==========================================================================
% Lorentz or Guassian ,then apodization
%==========================================================================
    % Lorentz shape
    if u_events{1}(2) == 0
        aposig = exp(-aplw * pi * t);
    % Gaussian shape
    elseif u_events{1}(2) == 1
        aposig = exp(-sign(aplw) * aplw * aplw * pi * t .* t);
    end

    % singnal processing
    fsignal=complexFidData.*aposig';  
end